package com.ymatou.iapi.godmch.testcase;

import java.util.Arrays;
import java.util.List;

import net.sf.json.JSONObject;

import org.json.JSONArray;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.dguser.parameter.UserCreateBean;
import com.ymatou.iapi.godmch.parameter.createmchBean;
import com.ymatou.iapi.godmch.parameter.getOptionalSettlementCurrencyBean;
import com.ymatou.iapi.godmch.service.getOptionalSettlementCurrencyCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.DGUserCallService;
import com.ymttest.business.service.shenqi.GodmchManageCallService;
import com.ymttest.database.model.godmch.chargeconfig;
/**
*获取商户可切换的结算币种
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_getOptionalSettlementCurrency{
	private static getOptionalSettlementCurrencyBean bean;
	private static getOptionalSettlementCurrencyCall call;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("获取商户可切换的结算币种");
	}

	@Before
	public void caseUp() {
		bean=new getOptionalSettlementCurrencyBean();
		call=new getOptionalSettlementCurrencyCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(call.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getOptionalSettlementCurrency_001() {
		Logger.start(true,"获取商户可切换的结算币种-传入返回商户的结算币种 +disconf配置的可选币种-成功");
		try {
			//创建渠道
            Integer mchId = GodmchManageCallService.CreateSellerMch();
            bean.setMchId(mchId);
			call.setData(bean);
			call.callService();			
			Logger.verifyEquals("200", call.getStatus1(), "验证status");
			
			String strs=new org.json.JSONObject(call.getReturnData()).getJSONObject("result").get("settlementCurrencList").toString();
			
			//List list=Arrays.asList(strs);
			if(strs.contains("USD") && strs.contains("HKD") 
					&& strs.contains("GBP")&& strs.contains("EUR")&& strs.contains("JPY"))
			   Logger.verifyEquals(true, true, "验证包含");
			else 
				Logger.verifyEquals(false, true, "验证不包含");
				
				
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getOptionalSettlementCurrency_001_1() {
		Logger.start(true,"获取商户可切换的结算币种-商户的币种不含disconf-支持本土币种国家CAN-成功");//CHE 不支持本土
		try {
			//创建渠道
			UserCreateBean usercreateBean2 = DGUserCallService.initSellerUsercreateBean();
			int mchId = DGUserCallService.UserCreateCall(usercreateBean2);
			createmchBean createBean1=GodmchManageCallService.InitcreatemchBeanForChannel(mchId);
			createBean1.setCountry("CAN");
			GodmchManageCallService.createmchCallForChannel(createBean1);
			
            bean.setMchId(mchId);
			call.setData(bean);
			call.callService();			

	       Logger.verifyEquals("200", call.getStatus1(), "验证status");
		   String strs=new org.json.JSONObject(new org.json.JSONObject(call.getReturnData()).getString("result"))
		   .get("settlementCurrencList").toString();

			if(strs.contains("CAD") && strs.contains("USD") && strs.contains("HKD") 
					&& strs.contains("GBP")&& strs.contains("EUR")&& strs.contains("JPY"))
			   Logger.verifyEquals(true, true, "验证包含");
			else 
				Logger.verifyEquals(false, true, "验证不包含");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getOptionalSettlementCurrency_001_2() {
		Logger.start(true,"获取商户可切换的结算币种-商户的币种不含disconf-不支持本土币种国家CHE,返回USD-成功");//CHE 不支持本土
		try {
			//创建渠道
			UserCreateBean usercreateBean2 = DGUserCallService.initSellerUsercreateBean();
			int mchId = DGUserCallService.UserCreateCall(usercreateBean2);
			createmchBean createBean1=GodmchManageCallService.InitcreatemchBeanForChannel(mchId);
			createBean1.setCountry("CHE");
			GodmchManageCallService.createmchCallForChannel(createBean1);
			
            bean.setMchId(mchId);
			call.setData(bean);
			call.callService();			
	        Logger.verifyEquals("200", call.getStatus1(), "验证status");
		    String strs=new org.json.JSONObject(new org.json.JSONObject(call.getReturnData()).getString("result"))
			.get("settlementCurrencList").toString();

			if(strs.contains("USD") && strs.contains("HKD") 
					&& strs.contains("GBP")&& strs.contains("EUR")&& strs.contains("JPY"))
			   Logger.verifyEquals(true, true, "验证包含");
			else 
				Logger.verifyEquals(false, true, "验证不包含");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getOptionalSettlementCurrency_002() {
		Logger.start(true,"获取商户可切换的结算币种-不传获取disconf配置的可选币种-成功");
		try {
			
			call.setData(bean);
			call.callService();			
			
		   Logger.verifyEquals("200", call.getStatus1(), "验证status");
		   String strs=new org.json.JSONObject(new org.json.JSONObject(call.getReturnData()).getString("result"))
		   .get("settlementCurrencList").toString();
		
			if(strs.contains("USD") && strs.contains("HKD") 
			&& strs.contains("GBP")&& strs.contains("EUR")&& strs.contains("JPY"))
			   Logger.verifyEquals(true, true, "验证包含");
			else 
				Logger.verifyEquals(false, true, "验证不包含");
				
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getOptionalSettlementCurrency_003() {
		Logger.start(true,"获取商户可切换的结算币种-传入错误的商户-返回disconf配置的币种-失败");
		try {
			bean.setMchId(99009009);
			call.setData(bean);
			call.callService();		
			
			 Logger.verifyEquals("200", call.getStatus1(), "验证status");
			  String strs=new org.json.JSONObject(new org.json.JSONObject(call.getReturnData()).getString("result"))
			  .get("settlementCurrencList").toString();
			
			if(strs.contains("USD") && strs.contains("HKD") 
			&& strs.contains("GBP")&& strs.contains("EUR")&& strs.contains("JPY"))
			   Logger.verifyEquals(true, true, "验证包含");
			else 
				Logger.verifyEquals(false, true, "验证不包含");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
}